package com.colt.usercenter.rocketmq;

import com.colt.usercenter.dao.bonuseventlog.BonusEventLogMapper;
import com.colt.usercenter.domain.dto.message.UserUpdateBonusMsgDTO;
import com.colt.usercenter.rocketmq.sink.BonusCostSink;
import com.colt.usercenter.service.user.impl.UserServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @program: user-center
 * @description: 测试消费
 * @author: colt
 * @create: 2020-09-04 15:37
 **/
@Service
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UpdateBonusStreamConsumor {
    private final UserServiceImpl userService;
    @StreamListener(value = Sink.INPUT)
    public void receive(UserUpdateBonusMsgDTO message){
        userService.addBonus(message);
    }
    @StreamListener(value = BonusCostSink.COSTBONUS_INPUT)
    public void costBonus(UserUpdateBonusMsgDTO message){
        System.err.println(message);
        userService.costBonus(message);
    }
    /*@StreamListener(value = Sink.INPUT,condition = "headers['auto-header']=='hhhh'")
    public void receiveByheader(String messageBody){
        System.err.println("receiveByheader：messageBody = "+messageBody);
      log.info("通过stream收到了消息：messageBody = {}",messageBody);
    }*/

}
